
let dataSource = [
    {
      key: '1',
      userCode: 'zhangsan',
      password: '123456'
    },
    {
        key: '2',
        userCode: 'lisi',
        password: '123456'
      }
  ];

//新增测试数据
const login = (req, res) => {
//获取请求体中的入参
const { userCode, password} = req.body;

    const existingData = dataSource.filter(item => item.userCode === userCode && item.password === password);
    if (existingData.length > 0) {
        // 如果存在，则覆盖原有数据
        res.send({ error_code: 0, error_msg: 'OK', data: existingData });
    } else {
        // 如果不存在，则添加新数据
        res.send({ error_code: -1 });
    }
}

export default {
'POST /api/login': login,
};